//
// Created by 123 on 2025/1/8.
//
#include "list"
#include "string"
#include "iostream"
using namespace std;

class Person{
public:
    string name;
    int age;
    int height;
public:
    Person(string name,int age,int height){
        this->name = name;
        this->age = age;
        this->height = height;
    }
};

void printPerson(const list<Person>& li){
    for(list<Person>::const_iterator it=li.begin();it!=li.end();it++){
        cout << "name:" << (*it).name << " age:" << (*it).age << " height:" << (*it).height << " ";
    }
    cout << endl;
}

//年龄升序，身高降序，//返回true就是交换
bool ComparePerson(Person& p1,Person& p2){
    if(p1.age == p2.age){
        return p1.height>p2.height;
    }else{
        return p1.age<p2.age;
    }
}

void test(){
    Person p1("111",11,180);
    Person p2("222",8,150);
    Person p3("333",11,172);
    list<Person> li;
    li.push_back(p1);
    li.push_back(p2);
    li.push_back(p3);

    printPerson(li);
    cout << "==========================" << endl;
    li.sort(ComparePerson);
    printPerson(li);
}

int main136(){
    test();
    return 0;
}
